<!--内联style方式绑定-->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Vue中的样式绑定3</title>
    <script src="./vue.js"></script>
</head>
<body>
    
    <div id="app">
        <div :style="styleObj" @click="handleDivClick">
            Hello world
        </div>
    </div>

    <script>
        var vm = new Vue({
            el: "#app",
            data: {
                styleObj: {
                    color: "black"
                }
            },
            methods: {
                handleDivClick: function () {
                    this.styleObj.color = this.styleObj.color === "black" ?
                        "red" : "black";
                }
            }
        })
    </script>
</body>
</html>